<!DOCTYPE html>
<html lang="en">

<head>
    <!-- META DATA -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->

    <!-- TITLE OF SITE -->
    <title>伯俊微后台</title>
    <!--linear icon css-->
    <link rel="stylesheet" href="assets/css/icon-font.min.css">
    <!--bootstrap.min.css-->
    <link rel="stylesheet" href="assets/css/bootstrap.min.css">
    <link rel="stylesheet" href="assets/css/search_box.css">
    <!--style.css-->
    <link rel="stylesheet" href="assets/css/style.css">
    <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/4.7.0/css/font-awesome.css">


    <style>

        #shht {
            box-shadow: 0 0 7px #c8c8c8;
            display: none;
        }


    </style>
    <style>
        * {
            margin: 0;
            padding: 0;
            list-style: none;
        }

        a {
            text-decoration: none;
        }

        a:hover {
            text-decoration: none;
        }

        .tcdPageCode {
            padding: 15px 20px;
            /*text-align: left;*/
            color: #ccc;
            text-align: center;
        }

        .tcdPageCode a {
            display: inline-block;
            color: #428bca;

            height: 25px;
            line-height: 25px;
            padding: 0 10px;
            border: 1px solid #ddd;
            margin: 0 2px;
            border-radius: 4px;
            vertical-align: middle;
        }

        .tcdPageCode a:hover {
            text-decoration: none;
            border: 1px solid #428bca;
        }

        .tcdPageCode span.current {
            display: inline-block;
            height: 25px;
            line-height: 25px;
            padding: 0 10px;
            margin: 0 2px;
            color: #fff;
            background-color: #428bca;
            border: 1px solid #428bca;
            border-radius: 4px;
            vertical-align: middle;
        }

        .tcdPageCode span.disabled {
            display: inline-block;
            height: 25px;
            line-height: 25px;
            padding: 0 10px;
            margin: 0 2px;
            color: #bfbfbf;
            background: #f2f2f2;
            border: 1px solid #bfbfbf;
            border-radius: 4px;
            vertical-align: middle;
        }


        .table > tbody > tr > td {

            line-height: 50px;
            /*background-color: #e7e0e0;*/

        }

        .input-value {

            width: 90%;
            height: 34px;
            padding: 6px 12px;
            font-size: 14px;
            line-height: 1.42857143;
            color: #555;
            background-color: #fff;
            background-image: none;
            border: 1px solid #ccc;
            border-radius: 4px;
        }

        #btsbm {
            border: 0;
            text-decoration: none;
            background: #34ac26;
            color: #f2f2f2;

            padding: 10px 20px 10px 20px;
            margin-left: 42%;
            font-size: 16px;
            font-family: 微软雅黑, 宋体, Arial, Helvetica, Verdana, sans-serif;
            font-weight: bold;
            border-radius: 3px;

            -webkit-transition: all linear 0.30s;
            -moz-transition: all linear 0.30s;
            transition: all linear 0.30s;
        }

        select {
            width: 30%;
            height: 34px;
            padding: 6px 12px;
            font-size: 14px;
            line-height: 1.42857143;
            color: #555;
            background-color: #fff;
            background-image: none;
            border: 1px solid #ccc;
            border-radius: 4px;
        }
    </style>
    <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/4.7.0/css/font-awesome.css">

</head>

<body style="background-color:#ffffff;font-family: Helvetica Neue,Helvetica,PingFang SC,Hiragino Sans GB,Microsoft">

<!-- wrapper -->
<div id="wrapper">

    <!-- navbar -->
    <nav class="navbar navbar-default navbar-fixed-top">
        <div class="brand" style="overflow: hidden;width: 12.6%;">
            <a href="vip-pos.html">
                <!--<img src="assets/images/logo1.png" style="display: block;width: 100%;margin: 0 auto;">-->
                <h2 style="color: #fcfdfd">控制台</h2>
            </a>
        </div><!--/.brand -->
        <div class="container-fluid">
            <div class="navbar-btn">
                <button type="button" class="btn-toggle-fullwidth">
                    <i class="lnr lnr-arrow-left-circle"></i>
                </button>
            </div><!--/.navbar-btn -->
            <form class="navbar-form navbar-left" style="margin-bottom: 0;">
                <div style="line-height: 50px;font-weight: bold;">
                    <a href="index.html"
                       style="display: block;float: left;padding: 0 15px;margin: 0 10px;cursor: pointer;padding-bottom: 10px;;">总览</a>
                    <a href="javascript:void(0);" id="shht-sj"
                       style="display: block;float: left;padding: 0 15px;margin: 0 10px;cursor: pointer;padding-bottom: 10px;">
                        商户后台
                        <span class="fa fa-angle-down"
                              style="font-size:25px;position: absolute;margin: 12px 0 0 2px;">  </span>
                    </a>
                    <a href="bos-config.html"
                       style="display: block;float: left;padding: 0 15px;margin: 0 10px;cursor: pointer;padding-bottom: 10px;">系统设置</a>
                    <a href="wechat-index.html"
                       style="display: block;float: left;padding: 0 15px;margin: 0 10px;cursor: pointer;padding-bottom: 10px;">微生活</a>
                </div>
            </form><!--/form -->
            <div id="shht"
                 style="width: 500px;height: 300px;position: absolute;top: 67px;left: 100px;background-color: #fcfdfd">

                <div style="margin-left: 180px;">
                    <h4 style=" margin: 40px 0 22px 35px; color: black; font-size: 15px;">
                        <b>会员管理</b></h4>
                    <ul style="list-style:none;font-size: 12px;margin: 20px 0 30px 35px;">
                               <li style="margin: 15px 0 0 0;"><a href="vip-wx.html">会员列表</a></li>
                        <li style="margin: 15px 0 0 0;"><a href="vip-label.html">会员标签</a></li>
                       <!-- <li style="margin: 15px 0 0 0;"><a href="#">会员列表</a></li>-->
                    </ul>
                </div>

                <div style="margin-left: 70px;margin-top: -148px;">
                    <h4 style=" margin: 62px 0 22px 35px; color: black; font-size: 15px;">
                        <b>门店管理</b></h4>
                    <ul style="list-style:none;font-size: 12px;margin: 20px 0 30px 35px;">
                         <li style="margin: 15px 0 0 0;"><a href="store.html">门店列表</a></li>
                                                               <!-- <li style="margin: 15px 0 0 0;"><a href="#">门店体系</a></li>
                         <li style="margin: 15px 0 0 0;"><a href="#">门店状态</a></li>-->
                    </ul>
                </div>
                <div style="margin-left: 70px;">
                    <h4 style=" margin: 62px 0 22px 35px; color: black; font-size: 15px;">
                        <b>营销活动</b></h4>
                    <ul style="list-style:none;font-size: 12px;margin: 20px 0 30px 35px;">
                        <li style="margin: 15px 0 0 0;"><a href="coupon-y.html">优惠券</a></li>
                        <li style="margin: 15px 0 0 0;"><a href="activity.html">活动管理</a></li>
                    </ul>
                </div>

            </div>
            <div class="navbar-menu">
                <ul class="nav navbar-nav navbar-right">

                    <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                            <!--<img src="assets/images/parson.png" class="img-circle" alt="parson-img">-->
                            <span style="font-size: 15px;color: #000;">账户信息</span>
                            <i class="icon-submenu fa fa-angle-down"></i>
                        </a>
                        <ul class="dropdown-menu">
                            <li><a href="#"><i class="lnr lnr-user"></i> <span>账户信息</span></a></li>
                            <li><a href="change-password.html"><i class="lnr lnr-cog"></i> <span>修改密码</span></a></li>
                            <li id="e-exit"><a href="#"><i class="lnr lnr-envelope"></i> <span>退出登录</span></a></li>
                        </ul>
                    </li>
                </ul>
            </div>
        </div>

    </nav>


    <!-- LEFT SIDEBAR -->
    <div id="sidebar-nav" class="sidebar">
        <div class="sidebar-scroll">
            <h3 style="color: #ffffff;padding: 0 0 0 8%">营销活动</h3>
            <nav>
                <ul class="nav">
                    <li>
                        <a href="activity.html">
                            <span style="padding: 0 0 0 30px;">活动管理</span>
                        </a>
                    </li>
                    <li class="active">
                        <a href="complement-config.html">
                            <span style="padding: 0 0 0 30px;">会员任务</span>
                        </a>
                    </li>

                </ul>
            </nav>
        </div>

    </div>
    <!-- END LEFT SIDEBAR -->

    <!-- MAIN -->
    <div class="main">
        <div style="padding-right: 2%;">

            <div style="text-align: left"><h3 style="padding-left: 2%;">新增</h3></div>
            <div style="margin: 2%;height: 25px">
                <div style="float: left;width: 5%;padding-top: 5px;">名称：</div>
                <input type="text" class="input-value" id="bt-name" style="float: left;width: 85%;">
            </div>

            <div style="margin: 2%;height: 25px">
                <span>
                    <div style="float: left;width: 5%;padding-top: 5px;">类型：</div>
                <select id="bt-tags" style="float: left;width: 30%;">
                    <option></option>
                </select>
                </span>
                <span>
                     <div style="float: left;width: 5%;margin-left: 5%;padding-top: 5px;">积分：</div>
                <input type="text" class="input-value" id="bt-award" style="float: left;width: 45%;">

                </span>
            </div>


            <input type="button" value="添加" id="btsbm" onclick="add()">
        </div>
        <div style="width: 100%;height: 20px;background-color: #ffffff;margin-top: 2%"></div>
        <table class="table">

            <colgroup>
                <col width="120">
                <col width="40">
                <col width="40">
                <col width="40">

            </colgroup>
            <thead>
            <tr>
                <td>名称</td>
                <td>类型</td>
                <td>积分</td>
                <td>操作</td>
            </tr>
            </thead>
            <tbody id="data">
            <tr>
                <td>123</td>
                <td>123</td>
                <td>123</td>
                <td style="padding-top: 1.5%;text-align: center">
                    <i style="font-size:24px;color:#db3230;" class="fa fa-times" onclick="del(1)"></i>
                </td>
            </tr>

            </tbody>
        </table>

        <!--分页栏-->
        <div>
            <div class="tcdPageCode" style="height: 100px;"></div>
        </div>


    </div>

</div>
<!-- END MAIN -->

<div class="clearfix"></div>


</div>
<!-- END WRAPPER -->


<script src="js/jquery.min.js"></script>


<script src="assets/js/fontawesome-all.min.js"></script>
<script src="assets/js/bootstrap.min.js"></script>


</body>
<script src="assets/js/jq.page.js"></script>

<script>
    $("#shht-sj,#shht").hover(function () {
        // 鼠标移入时添加hover类

        $("#shht").css('display', 'inline')
    }, function () {
        // 鼠标移出时移出hover类
        $("#shht").css('display', 'none')
    });

</script>
<script>
    $(document).ready(
        getTags(), show()
    );

    function del(id) {
        $.ajax({
            "url": "/complement/del/",
            "data": "id="+id,
            "type": "POST",
            "dataType": "json",
            "success": function (json) {
                if (json.state ==200){
                    alert("删除成功");
                    $("#tr"+id).remove();
                } else {
                    alert(json.message);
                }
            }
        })
    }

    function show() {

        $.ajax({
            "url": "/complement/show/",
            "type": "POST",
            "dataType": "json",
            "success": function (json) {
                $("#data").empty();
                if (json.state == 200) {
                    for (var i = 0; i < json.data.length; i++) {
                        var map = json.data[i];
                        var html = '<tr id="tr#{id}">' +
                            '<td>#{name}</td>' +
                            '<td>#{code}</td>' +
                            '<td>#{award}</td>' +
                            '<td style="padding-top: 1.5%;text-align: center">' +
                            '<i style="font-size:24px;color:#db3230;" class="fa fa-times" onclick="del(#{id})"></i>' +
                            '</td>'+
                            '</tr>';
                        html = html.replace("#{name}", map.name);
                        html = html.replace("#{code}", map.code);
                        html = html.replace("#{award}", map.award);
                        html = html.replace("#{id}", map.id);
                        html = html.replace("#{id}", map.id);
                        $("#data").append(html);

                    }
                }
            }

        })
    }

    function add() {
        var name = $("#bt-name").val();
        var tags = $("#bt-tags").val();
        var award = $("#bt-award").val();
        var code = $("#bt-tags option:selected").text();
        if (isNaN(award)||award.length>8||name.length>15){
            alert("填写正确信息");
            return;
        }

        if (name.length==0||tags.length==0||award.length==0){
            alert("请填写信息");
            return;
        }
        $.ajax({
            "url": "/complement/create/",
            "data": "name=" + name + "&code=" + code+"&award="+award+"&codeId=" + tags,
            "type": "POST",
            "dataType": "json",
            "success": function (json) {
                if (json.state == 200) {
                    alert("添加成功");
                    location.reload()
                } else {
                    alert(json.message);
                }
            }
        })
    }

    function getTags() {
        $.ajax({
            "url": "/viptags/getbos/",
            "type": "POST",
            "dataType": "json",
            "success": function (json) {

                if (json.state == 200) {
                    var list = json.data.set;

                    for (var i = 0; i < json.data.set.length; i++) {
                        var map = list[i];
                        console.log(map);
                        var html = '<option value="#{id}">#{name}</option>';
                        html = html.replace("#{name}", map.name);
                        html = html.replace("#{id}", map.id);
                        $("#bt-tags").append(html);
                    }
                } else {
                    alert("标签数据错误")
                }
            }
        })
    }
</script>
<script>
    $("#e-exit").click(function () {
        $(document).ready(
            $.ajax({
                "url": "/backend/exit/",
                "type": "POST",
                "success": function () {

                    location.href = "login-system.html"

                }
            }))
    })
</script>
</html>